home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / shrlk201.zip / _SETUP.1 / Test.cpp < prev    next >
C/C++ Source or Header  |  1997-07-22  |  5KB  |  168 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Test.h"
  6. #include "Help.h"
  7. //---------------------------------------------------------------------------
  8. #pragma link "nsShareLock"
  9. #pragma resource "*.dfm"
  10. TfrmTester *frmTester;
  11. //---------------------------------------------------------------------------
  12. __fastcall TfrmTester::TfrmTester(TComponent* Owner)
  13.     : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TfrmTester::mnuMain_Help_AboutClick(TObject *Sender)
  18. {
  19. frmAboutTester->ShowModal();
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TfrmTester::FormCreate(TObject *Sender)
  23. {
  24.   Height = 82;
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TfrmTester::FormShow(TObject *Sender)
  28. {
  29.   ShareLock->CheckProtection();
  30.   DoStatus();
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TfrmTester::sbtnStatusClick(TObject *Sender)
  34. {
  35.   if (sbtnStatus->Down)
  36.     {
  37.       Height = 252;
  38.       sbtnStatus->Caption = "Status <<";
  39.     }
  40.   else
  41.     {
  42.      Height = 82;
  43.      sbtnStatus->Caption = "Status >>";
  44.     };
  45. }
  46.  
  47. //---------------------------------------------------------------------------
  48.  
  49. void __fastcall TfrmTester::DoStatus()
  50. {
  51.   lblTryOut->Caption = IntToStr(ShareLock->TryNumber);
  52.   lblProductName_Out->Caption = ShareLock->ProgramName;
  53.   lblDLLVersion_Out->Caption = ShareLock->DLLVersion;
  54.  
  55.   switch (ShareLock->Protection) {
  56.     case ptRunCount:
  57.       {
  58.         lblProtectionType_Out->Caption = "Run Count";
  59.         if ((ShareLock->TrialPeriodRemaining <= 0) && (ShareLock->GracePeriod > 0)) lblDaysLeft_Out->Caption = IntToStr( ShareLock->TrialPeriodRemaining);
  60.         else lblDaysLeft_Out->Caption = IntToStr(ShareLock->TrialPeriodRemaining);
  61.         lblExpireDate_Out->Caption = "N/A";
  62.         lblGraceExpire_Out->Caption = "N/A";
  63.         lblDaysLeft->Caption = "Runs Left";
  64.         lblTrialLength_Out->Caption = IntToStr(ShareLock->TrialLength);
  65.         lblGracePeriod_Out->Caption = IntToStr(ShareLock->GracePeriod);
  66.         break;
  67.       }
  68.     case ptSpecificDate, ptNumberDays:
  69.       {
  70.         switch (ShareLock->Protection)
  71.           {
  72.           case ptSpecificDate:
  73.             {
  74.             lblProtectionType_Out->Caption = "Specific Date";
  75.             break;
  76.             }
  77.           case ptNumberDays:
  78.             {
  79.             lblProtectionType_Out->Caption = "Number Days";
  80.             break;
  81.             }
  82.           }
  83.         lblDaysLeft_Out->Caption = IntToStr(ShareLock->TrialPeriodRemaining);
  84.         lblDaysLeft->Caption = "Days Left";
  85.         lblExpireDate_Out->Caption = FormatDateTime("ddddd", ShareLock->ExpirationDate);
  86.         lblGraceExpire_Out->Caption = FormatDateTime("ddddd", ShareLock->ExpirationDate + ShareLock->GracePeriod);
  87.         lblTrialLength_Out->Caption = IntToStr(ShareLock->TrialLength);
  88.         lblGracePeriod_Out->Caption = IntToStr(ShareLock->GracePeriod);
  89.         break;
  90.       }
  91.     case ptNoExpire:
  92.       {
  93.         lblProtectionType_Out->Caption = "No Expire";
  94.         lblExpireDate_Out->Caption = "N/A";
  95.         lblGraceExpire_Out->Caption = "N/A";
  96.         lblTrialLength_Out->Caption = "N/A";
  97.         lblGracePeriod_Out->Caption = "N/A";
  98.         lblDaysLeft_Out->Caption = "N/A";
  99.         break;
  100.       }
  101.   }
  102.  
  103.   switch (ShareLock->Status)
  104.   {
  105.     case stTrialPeriod:
  106.       {
  107.         lblStatus_Out->Caption = "Trial Period";
  108.         break;
  109.       }
  110.     case stRegistered:
  111.       {
  112.         lblStatus_Out->Caption = "Registered";
  113.         break;
  114.       }
  115.     case stGracePeriod:
  116.       {
  117.         lblStatus_Out->Caption = "Grace Period";
  118.         break;
  119.       }
  120.     case stExpired:
  121.       {
  122.         lblStatus_Out->Caption = "Expired";
  123.         break;
  124.       }
  125.   }
  126. }
  127. //---------------------------------------------------------------------------
  128.  
  129. void __fastcall TfrmTester::mnuMain_Help_TestAboutClick(TObject *Sender)
  130. {
  131.   ShareLock->DisplayAboutDialog();
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TfrmTester::ShareLockSuggestTerminate(int Reason)
  135. {
  136.   switch (Reason)
  137.     {
  138.     case 1: //Exceeded Tries
  139.       {
  140.       Application->Terminate();
  141.       break;
  142.       }
  143.     case 2: //CannotOpenRegistry
  144.       {
  145.       Application->Terminate();
  146.       break;
  147.       }
  148.     case 3: //Clock moved back
  149.       {
  150.       Application->Terminate();
  151.       break;
  152.       }
  153.     }
  154.  
  155. }
  156. //---------------------------------------------------------------------------
  157. void __fastcall TfrmTester::mnuMain_Help_RegisterClick(TObject *Sender)
  158. {
  159.   ShareLock->DisplayRegistrationDialog();
  160.   DoStatus();
  161. }
  162. //---------------------------------------------------------------------------
  163. void __fastcall TfrmTester::mnuMain_File_ExitClick(TObject *Sender)
  164. {
  165.   Close();
  166. }
  167. //---------------------------------------------------------------------------
  168.